package com.zscat.mallplus.center.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zscat.mallplus.center.BaseController;
import com.zscat.mallplus.center.entity.CenterInvoice;
import com.zscat.mallplus.center.service.ICenterInvoiceService;
import com.zscat.mallplus.utils.CommonResult;

/**
 * 发票信息Controller
 * 
 * @author Wsen
 * @date 2020-09-20
 */
@RestController
@RequestMapping("/center/invoice")
public class CenterInvoiceController extends BaseController
{
    @Autowired
    private ICenterInvoiceService centerInvoiceService;

    /**
     * 查询发票信息列表
     */
//    @PreAuthorize("@ss.hasPermi('center:invoice:list')")
    @GetMapping("/list")
    public Object list(CenterInvoice centerInvoice)
    {
        List<CenterInvoice> list = centerInvoiceService.selectCenterInvoiceList(centerInvoice);
        return new CommonResult().success(list);
    }

    /**
     * 获取发票信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('center:invoice:query')")
    @GetMapping(value = "/{id}")
    public Object getInfo(@PathVariable("id") Long id)
    {
        return new CommonResult().success(centerInvoiceService.selectCenterInvoiceById(id));
    }

    /**
     * 新增发票信息
     */
//    @PreAuthorize("@ss.hasPermi('center:invoice:add')")
    @PostMapping
    public Object add(@RequestBody CenterInvoice centerInvoice)
    {
        return toAjax(centerInvoiceService.insertCenterInvoice(centerInvoice));
    }

    /**
     * 修改发票信息
     */
//    @PreAuthorize("@ss.hasPermi('center:invoice:edit')")
    @PutMapping
    public Object edit(@RequestBody CenterInvoice centerInvoice)
    {
        return toAjax(centerInvoiceService.updateCenterInvoice(centerInvoice));
    }

    /**
     * 删除发票信息
     */
//    @PreAuthorize("@ss.hasPermi('center:invoice:remove')")
	@DeleteMapping("/{ids}")
    public Object remove(@PathVariable Long[] ids)
    {
        return toAjax(centerInvoiceService.deleteCenterInvoiceByIds(ids));
    }
}
